package cn.cxq.learning.stack;

import java.util.Scanner;
import java.util.Stack;

/**
 * 腾讯校招题 压缩
 */
public class Zip {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        String s = scanner.nextLine();

        StringBuffer sb = new StringBuffer();

        for (Character c : s.toCharArray()) {
            if (c != '[') {
                sb.append(c);
            }
        }

        s = sb.toString();

        char[] ss = s.toCharArray();

        String res = "";
        int multi = 0;

        Stack<Integer> numStack = new Stack<>();
        Stack<String> strStack = new Stack<>();

        for (int i = 0; i < ss.length; i++) {
            if (ss[i] == '|') {
                strStack.push(res);
                numStack.push(multi);
                res = "";
                multi = 0;
            } else if (ss[i] > '0' && ss[i] < '9') {
                multi = multi * 10 + ss[i] - '0';
            } else if (ss[i] == ']') {
                StringBuffer buffer = new StringBuffer();
                buffer.append(strStack.pop());
                int number = numStack.pop();
                while (number -- > 0) {
                    buffer.append(res);
                }
                res = buffer.toString();
            } else {
                res +=String.valueOf(ss[i]);
            }
        }

        System.out.println(res);
    }
}
